import java.util.Scanner;

public class Main {
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的四位密码");
        int num = sc.nextInt();

        //优化之后
        System.out.printf("第二次加密后的密码：%04d",getPassword(num));
        sc.close();
    }

    public static int getPassword(int num){
        if (num+"".length()<4){
            System.out.println("你输入的密码过短");
            return 0;
        }

        //将num拆解为了个位十位百位千位, 拿到了每个数字之后就加密
        int a = (num%10)*5%3;
        int b = (num/10%10)*5%3;
        int c = (num/100%10)*5%3;
        int d = (num/1000%10)*5%3;

        //这里就可以拿到第一次的密码样本
        System.out.println("第一次加密后的密码："+d+c+b+a);

        //第二次加密
        b *= 1000;
        a *= 100;
        d *= 10;

        return a+b+c+d;
    }
}
